{% extends 'app01/admin/home.html' %}


 {% block content %}
                <div class="panel panel-default">
                    <div class="panel-heading">老师管理</div>
                    <div class="panel-body">
                        <table class="table-hover table table-hover">
                            <thead>
                            <tr>
                                <th>职工号</th>
                                <th>姓名</th>
                                <th>邮箱</th>
                                <th>手机</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for student in c_page %}
                                <tr>
                                    <td>{{ student.username }}</td>
                                    <td>{{ student.username }}</td>
                                    <td>{{ student.email }}</td>
                                    <td>{{ student.phone }}</td>
                                    <td><a type="button" style="color: indianred" class="del_btn" del_id="{{ student.id }}">删除</a></td>
                                </tr>

                            {% endfor %}

                            </tbody>
                        </table>
                    </div>
                </div>
                {# 分页显示 #}
                <div class="pager">
                    <nav aria-label="Page navigation">
                        <ul class="pagination">
                            {{ page_html }}
                        </ul>
                    </nav>
                </div>
            {% endblock %}
{% block js %}
    <script>
        $('.del_btn').click(function () {
            //删除的二次确认
            let op = confirm('确认删除吗？')
            let del_id=$(this).attr('del_id')
              $.ajax({
            url:'',
            type:'post',
            data:{'del_id':del_id,'op':op},
            success:function (array) {
                if (array.code===100){
                    alert(array.msg)
                    window.location.reload()
                }
                else if( array.code===200 && op===true){
                    alert(array.msg)
                }

            }
        })
        });

//鼠标获取焦点时，错误信息不显示了。
        $('#id_confirm_pwd').focus(function () {
            $('#error').text('')

        })


    //修改密码的ajax请求

    $('#id_editer').click(function () {

        let old_pwd = $('#id_old_pwd').val()
        let new_pwd = $('#id_new_pwd').val()
        let comfir_pwd = $('#id_confirm_pwd').val()

        $.ajax({
            url:'/app01/set_password/',
            type: 'post',
            data:{'old_pwd':old_pwd,'new_pwd':new_pwd,'confirm_pwd':comfir_pwd},
            success:function (attr) {
                if(attr.code===1000){
                    alert(attr.msg)
                    window.location.reload()
                } else if(attr.code===2000){
                    $('#error').text(attr.msg)
                }else  if(attr.code===3000){
                    $('#error').text(attr.msg)
                }
            }
        })


    })


    </script>
{% endblock %}